﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QYmall.Core.Common.Redis
{
    /// <summary>
    /// Redis缓存接口
    /// </summary>
    public interface IRedisCacheManager
    {
        #region 同步方法
        /// <summary>
        /// 全部清除
        /// </summary>
        void Clear();

        /// <summary>
        /// 判断是否存在
        /// </summary>
        bool Get(string key);

        /// <summary>
        /// 获取 Reids 缓存值
        /// </summary>
        string GetValue(string key);

        /// <summary>
        /// 获取值，并序列化
        /// </summary>
        TEntity? Get<TEntity>(string key);

        /// <summary>
        /// 保存
        /// </summary>
        void Set(string key, object value, TimeSpan cacheTime);

        /// <summary>
        /// 移除某一个缓存值
        /// </summary>
        void Remove(string key);

        /// <summary>
        /// 模糊查找并设置过期时间
        /// </summary>
        void SetExpire(string pattern, TimeSpan cacheTime);

        /// <summary>
        /// 模糊查找删除匹配
        /// </summary>
        void RemovePattern(string pattern);
        #endregion
    }
}
